﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CreateSituation.aspx.cs" Inherits="Situation_CreateSituationExam" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>新建局级考试</title>
 

<link href="../../Common/css/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../Common/Js/jquery.js"></script>
<script type="text/javascript" src="../../Common/Js/common.js"></script>
<script type="text/javascript" src="../../Common/Js/msg.js"></script>
<style type="text/css">
 div{_behavior: url("../../Common/css/iepngfix.htc") }
</style> 
<script type="text/javascript">

function Load()
{
    var yearObj =  document.getElementById('selYear'); 
    if(yearObj != null)
    {   
        for(var i = 0; i < yearObj.options.length;i++)
        {
            var option = yearObj.options[i];
            
            if(Number(option.value) == Number("<%=currSchoolYear%>"))
            {
                option.selected  = "selected";
            }
            else
                 option.selected  = false;
        }
    }
    
    var termObj =  document.getElementById('selTerm'); 
    if(termObj != null)
    {    
        for(var i = 0; i < termObj.options.length;i++)
        {
            var option = termObj.options[i];
            
            if(Number(option.value) == Number("<%=currTerm%>"))
            {
                option.selected  = "selected"; 
            }
            else
                 option.selected  = false;
        }
    }
}

//关闭修改局级考试的遮罩层
function CloseCreateWindow()
{
    self.parent.CloseMask('popTable');
}


//创建局级考试
function CreateExam()
{
    var examName = document.getElementById('examName').value;
    if(examName == null || examName.length == 0)
    {
        showNoticMsg('examName','考试名不能为空',-250,10);  
        return ;
    }
    
    var yearObj = document.getElementById('selYear').options;
    var schoolYear = yearObj.options[yearObj.selectedIndex].value;
   
    var termObj = document.getElementById('selTerm').options;
    var term = termObj.options[termObj.selectedIndex].value;
    
    var gradeObj =  document.getElementById('selGrade').options;
    var grade = gradeObj.options[gradeObj.selectedIndex].value;
    
    var classTypeObj = document.getElementById('selClassType').options;
    var classType = classTypeObj.options[classTypeObj.selectedIndex].value;
   
    //构造一个考试
    var exam = {Name:examName,ClassType:classType,Grade:grade,Term:term,State:0,SchoolYear:schoolYear};
    
    var subjects = new Array();
    var checkItems=document.getElementById("divSubjects").getElementsByTagName('INPUT');
    for(var i=0;i < checkItems.length;i++){
　　　　var checkItem= checkItems[i];
　　　　if(checkItem.type==='checkbox' && checkItem.checked){
　　　　　 var subjectId= checkItem.value;
　　　　　 subjects.push(subjectId);
　　　　}
　　}
　　
　　if(subjects.length == 0)
　　{
　　    showNoticMsg('btnSave','您还没选择科目',-80,-80);  
　　    return;
　　}
　　
    PageMethods.CreateEduExam(exam,subjects,function(succ){
            Release();
           CloseCreateWindow();
           self.parent.showMassgeBox("提示","新建考试成功",1,null);
           self.parent.Bind();
       },function(err){
          showMassgeBox("提示",err._message,1,null);
    });
}

function SelGradeOnChange()
{
    var value = event.srcElement.value;

//    var obj = document.getElementById('selClassType');
//    if(obj != null)
//    {
//        if(value > 10)
//            obj.style.display = "block";
//        else
//            obj.style.display = "none";
//    }
    
}

//清空
function Release()
{
     document.getElementById('examName').value = "";
     var checkItems=document.getElementById("divSubjects").getElementsByTagName('INPUT');
     for(var j=0;j < checkItems.length;j++)
     {
         checkItems[j].checked = false;
     }
}

</script>
</head>
    
    
<body onload="Load();"  scroll="no">
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
        </asp:ScriptManager>
        <div class="mainWarp" style="height: 95%; overflow: auto; border-top: #9be0f0 1px solid;">
            <div class="pageBody">
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                 <ContentTemplate>
                      <table  style="width: 100%;border-style:hidden; border-bottom-color:#ffffff;">
                        <tr>
                           <td style="width: 15%; text-align: right;">名称：</td>
                           <td style="width: 85%; text-align: left;"><input id="examName" type="text" maxlength="45" style=" width:80%"
                           onKeypress="return (/^[a-zA-Z0-9\u4e00-\u9fa5]+$/g.test(String.fromCharCode(event.keyCode)))"
                           onblur="value=value.replace(/[^\u4e00-\u9fa5a-zA-Z0-9]/g ,'')"
                       
                           onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/></td>
                        </tr>
                        <tr>
                           <td style="text-align:right;">学年：</td>
                           <td style="text-align:left;">
                                <select id="selYear" style=" width:40%">
                                    <option value="2020">2020</option>
                                    <option value="2019">2019</option>
                                    <option value="2018">2018</option>
                                    <option value="2017">2017</option>
                                    <option value="2016">2016</option>
                                    <option value="2015">2015</option>
                                    <option value="2014">2014</option>
                                    <option value="2013">2013</option>
                                    <option value="2012">2012</option>
                                    <option value="2011">2011</option>
                                    <option value="2010">2010</option>
                                    <option value="2009" selected="selected">2009</option>
                                    <option value="2008">2008</option>
                                </select>
                                 <select id="selTerm" style=" width:40%">
                                    <option value="1">上学期</option>
                                    <option value="2">下学期</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align:right;">年级：</td>
                            <td style="text-align:left;">
                             
                                 <select id="selGrade" onchange="SelGradeOnChange();" style=" width:40%">
                                    <optgroup label="小学">
                                        <option value="1">一年级</option>
                                        <option value="2">二年级</option>
                                        <option value="3">三年级</option>
                                        <option value="4">四年级</option>
                                        <option value="5">五年级</option>
                                        <option value="6">六年级</option>
                                    </optgroup>
                                    <optgroup label="中学">
                                        <option value="7">初一</option>
                                        <option value="8">初二</option>
                                        <option value="9">初三</option>
                                    </optgroup>
                                    <optgroup label="高中">
                                         <option value="10">高一</option>
                                         <option value="11">高二</option>
                                         <option value="12">高三</option>
                                    </optgroup>   
                                </select>
                                
                                <select id="selClassType" style=" width:40%">
                                    <option value="0">不分科</option>
                                    <option value="1">文科</option>
                                    <option value="2">理科</option>
                                </select> 
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align:center;" colspan="2">
                                 <fieldset style=" width:90%; padding-top:10px;">
                                    <legend>考试科目</legend>
                                        <div id="divSubjects" style="height:140px; overflow:auto;">
                                            <table style="border-style:hidden; border-bottom-color:#ffffff; width:93%;table-layout:fixed;"> 
                                               <asp:Repeater ID="repeatSubject" runat="server">
                                                <ItemTemplate>    
                                                    <%# GetTD() %>
                                                </ItemTemplate>
                                               </asp:Repeater> 
                                            </table>
                                       </div>
                                </fieldset>
                                
                            </td>
                        </tr>
                    </table> 
                    <div style=" text-align:center;">
                     <ul class="butList">
                                    <li><input type="button"  id="btnSave" value="保存" onclick="CreateExam();" class="commonBut"/></li>
                                    <li><input type="button" value="取消" id="Button1"  onclick="CloseCreateWindow();" class="commonBut"/></li>
                                 </ul></div>
                 </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </div>
    </form>
</body>
</html>
